package com.aponteitor.business.dao;

import javax.persistence.NoResultException;

import com.aponteitor.business.model.Version;

/**
 * @author wellsantos@wellsantos.com
 */
public class VersionDao extends BaseDAO<Version, Long> {

    public Version findCurrent() {
        String sql = "select v from Version v where v.id = (select max(v2.id) from Version v2)";
        try {
            return (Version) getEntityManager().createQuery(sql).getSingleResult();
        } catch (NoResultException e) {
            return null;
        }
    }
}
